import { getOrganizationDeptSelect, getOrganizationSectionSelect, getOrganizationGroupSelect, getUserOrganization } from '@/services/ant-design-pro/api';

//获取部门数据
export const fetchDeptData = async () => {
    const response = await getOrganizationDeptSelect();
    return response.map((item: any) => ({
        label: item.deptdesc,     // ProFormSelect 需要的显示文本  
        value: item.dept,       // ProFormSelect 需要的实际值  
    }));
};
// 根据 dept 获取科室数据  
export const fetchSectionData = async (dept: number) => {
    const response = await getOrganizationSectionSelect({ dept: dept });
    return response.map((item: any) => ({
        label: item.secdesc, // ProFormSelect 需要的显示文本  
        value: item.section,       // ProFormSelect 需要的实际值  
    }));
};
// 根据 dept和 section 获取小组数据
export const fetchGroupData = async (dept: number, section: number) => {
    const response = await getOrganizationGroupSelect({ dept: dept, section: section });
    return response.map((item: any) => ({
        label: item.groupdesc, // ProFormSelect 需要的显示文本  
        value: item.group,       // ProFormSelect 需要的实际值  
    }));
};

// 根据 dept和 section和group 获取user数据
export const fetchUserOrganizaitonData = async (dept: number, section: number, group: number) => {
    return await getUserOrganization({ dept: dept, section: section, group: group });
};


// 封装请求数据的函数  
export const fetchDeptvaluelable = async () => {
    return await fetchDeptData();
};
// 封装请求数据的函数  
export const fetchSectionvaluelable = async (dept: number) => {
    return await fetchSectionData(dept);
};
// 封装请求数据的函数  
export const fetchGroupvaluelable = async (dept: number, section: number) => {
    return await fetchGroupData(dept, section);
};  
//封装请求数据的函数
export const fetchUserOrganizaiton = async (dept: number, section: number, group: number) => {
    return await fetchUserOrganizaitonData(dept, section,group);
};  